$(function () {
    //获取url
    var url = localStorage.getItem("ajaxUrl");
    //console.log(url);
    var djgd = JSON.parse(localStorage.getItem("djgd"));
    var pass = 1;

    $(".section span.batch").html(djgd.batch);
    $(".section span.gh").html(djgd.inventorySteel);
    $(".section span.zj").html(djgd.inventoryDiameter);
    $(".section span.zl").html(djgd.availableQuantity);
    //如果是 镀锌 默认为  不垫纸板

    //点击 返回 箭头
    $(".head .button-link").on("click", function () {
        localStorage.removeItem(djgd);
        window.location.href = "pack.html";
    });

    //点击 取消 按钮
    $(".foot .quxiao").on("click", function () {
        localStorage.removeItem(djgd);
        window.location.href = "pack.html";
    });

    //点击 确定 按钮
    $(".foot .queding").on("click", function () {
        var sxfs = $("select.sxfs").val();
        var sfdzb = $("select.sfdzb").val();
        if (pass == 0) {
            return
        }
        pass = 0;
        loading_show("打件中");
        $.ajax({
            headers: {authorization: "Bearer " + localStorage.getItem("jwt")},
            type: "post",
            url: url + '/app/split/djShouxian',
            data: {
                batch: djgd.batch,
                sxfs: sxfs,
                sfdzb: sfdzb
            },
            dataType: 'json',
            json: 'callback',
            success: function (res) {
                pass = 1;
                if (res.success) {
                    var data = res.result;
                    console.log(data);
                    loading_hide();
                    $alert("打件成功");
                    //打件 成功 跳转 页面
                    setTimeout(function () {
                        localStorage.removeItem(djgd);
                        window.location.href = "pack.html";
                    }, 1000);
                    // cordova.plugins.print.takeup(data.batch, (""), data.inventorySpecification, data.availableQuantity, data.inTime.slice(11, 16), data.inName, data.workplanNumber, data.stove, data.nextProcess, data.inResult, data.column, data.wirerodmanufacturerCode, function (result) {
                    // }, function error(error) {
                    // });
                } else {
                    $alert(res.message);
                }
            },
            error: function (error) {
                loading_hide();
                console.log(error);
                setTimeout(function () {
                    $("#goods_id").val("").focus();
                }, 1400);
                $alert(error.responseText);
            }
        });
    });

});
